package StringOperation;
//2011. 执行操作后的变量值
public class basic2011 {

    public int finalValueAfterOperations(String[] operations) {
                int x=0;
        for (int i = 0; i < operations.length; i++) {

            if (operations[i].equals("++X")||operations[i].equals("X++")){
                x++;
            }
            if (operations[i].equals("--X")||operations[i].equals("X--")){
                x--;
            }

        }
        return  x;

//        int ans = 0;
//
//        for (String operation : operations) {
//            // 操作类型
//            char op = operation.charAt(1); //第二个位置上一定是运算符号
//            switch (op) {
//                case '+':
//                    ans++;
//                    break;
//                case '-':
//                    ans--;
//                    break;
//            }
//        }
//
//        return ans;
    }

    public static void main(String[] args) {
        basic2011 basic2011 = new basic2011();
        int i = basic2011.finalValueAfterOperations(new String[]{"--X", "X++", "X++"});
        System.out.println(i);

    }
}
